
import java.io.File;

/*
 * To change this template, choose Tools | Templates and open the template in
 * the editor.
 */
/**
 *
 * @author 左志广
 */
public class DeleteFile {

    private File file;

    public DeleteFile(File file) {
        this.file = file;
    }

    private void deleteAllFiles() {
        internalDeleteAllFiles(file);
        file.delete();
    }

    private void internalDeleteAllFiles(File file) {
        File[] files = file.listFiles();
        for (File file1 : files) {
            if (file1.isDirectory()) {
                internalDeleteAllFiles(file1);
            }
            file1.delete();
        }
    }

    public static void main(String[] args) {
        //File file = new File("D://junit");
        File file = new File("D://test");
        DeleteFile df = new DeleteFile(file);
        df.deleteAllFiles();
    }
}
